// smallreport.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    inputContent:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '小报告'
    })
  },
  bindTextAreaBlur: function (e) {
    console.log(e.detail.value)
    var that = this
    that.setData({
      inputContent: e.detail.value
    })
  },
  bindFormSubmit: function (e) {
    var that = this
    var host = app.globalData.host
    var source = e.detail.value.textarea
    that.setData({
      inputContent: ''
    })
    if (source){
      wx.request({
        url: host + "/smallReportApi/addSmallReport",
        data: {
          content: source,
          thirdpartyId: wx.getStorageSync('openId'),
          name: wx.getStorageSync('userInfo').nickName
        },
        header: {
          'content-type': 'application/json'
        },
        success: function (res) {
          wx.showToast({
            title: '感谢您的宝贵意见！我们将根据您的反馈改正！',
            icon: 'success',
            duration: 2000
          })
        }
      })
    }else{
      wx.showToast({
        title: '请填写您的反馈',
        icon: 'success',
        duration: 2000
      })
    }  
  }
})